package 正则表达式.应用案例;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        // 目标: 校验用户输入的电话, 邮箱, 时间是否合法
        checkPhone();

    }

    public static void checkPhone() {
        System.out.println("请您输入您的电话号码(手机|座机)");
        Scanner sc = new Scanner(System.in);
        String phone = sc.nextLine();
        if (phone.matches("(1[3-9]\\d{9})|(0\\d{2,7}-?[1-9]\\d{4,19})")) {
            System.out.println("您输入的号码格式正确~~~");
        } else {
            System.out.println("您输入的号码格式不正确~~~");
        }
    }


    public static void checkEmail() {
        System.out.println("请您输入您的邮箱");
        Scanner sc = new Scanner(System.in);
        String email = sc.nextLine();
        if (email.matches("\\w{2,}@\\w{2,20}(\\.\\w{2,10}){1,2}")) {
            System.out.println("您输入的邮箱格式正确~~~");
        } else {
            System.out.println("您输入的邮箱格式不正确~~~");
        }
    }
}
